package neon;

import java.awt.Point;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.ArrayList;
import java.util.List;
import java.util.ListIterator;

public class NeonGroup implements MouseListener
{
	private final List<NeonButton> buttonList;
	private final List<NeonLabel> labelList;
	private final List<NeonList> listList;
	
	public NeonGroup()
	{
		this.buttonList = new ArrayList<NeonButton>();
		this.labelList = new ArrayList<NeonLabel>();
		this.listList = new ArrayList<NeonList>();
	}
	
	public void add(NeonButton button)
	{
		this.buttonList.add(button);
	}
	
	public void add(NeonLabel label)
	{
		this.labelList.add(label);
	}
	
	public void add(NeonList list)
	{
		this.listList.add(list);
	}


	@Override
	public void mouseClicked(MouseEvent e)
	{
	}

	@Override
	public void mouseEntered(MouseEvent e)
	{
	}

	@Override
	public void mouseExited(MouseEvent e)
	{
	}

	@Override
	public void mousePressed(MouseEvent e)
	{

	}
	
	public ListIterator<NeonButton> getButtonIterator()
	{
		return this.buttonList.listIterator();
	}
	
	public ListIterator<NeonLabel> getLabelIterator()
	{
		return this.labelList.listIterator();
	}
	
	public ListIterator<NeonList> getListIterator()
	{
		return this.listList.listIterator();
	}

	@Override
	public void mouseReleased(MouseEvent e)
	{
		ListIterator<NeonButton> ite = this.buttonList.listIterator();
		NeonButton temp = null;
		Point p = e.getPoint();
		boolean flag = true;
		
		while(flag && ite.hasNext())
		{
			temp = ite.next();
			
			if (temp.contains(p.x, p.y))
			{
				temp.doAction();
			}
		}
	}
}
